package com.jblog.controller.front.action.blog;

import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.jblog.controller.front.action.BaseAct;
import com.jblog.core.model.blog.Category;

@Controller
@RequestMapping("/category")
public class CategoryAct extends BaseAct {
    
    @RequestMapping(method = RequestMethod.GET)
    public String index(HttpServletRequest request, ModelMap model) {
        return "forward:/";
    }
    
    @RequestMapping(value = "/{alias}", method = RequestMethod.GET)
    public String alias(HttpServletRequest request, ModelMap model, @PathVariable String alias) {
        Category category = iblog.findCategoryByAlisa(alias);
        model.put("category", category);

        return F(request, model, "blog/main");
    }

}
